#pragma once

#include "dialog.h"
#include "dib.h"

#include <vector>

/** 
 * \ingroup ti6
 *
 * \brief
 * HistogramDialog is a subclass of Dialog, which represents a dialog
 * to show a histogram, for a single image (DIB).
 *
 * Copyright (c) Academie voor ICT en Media 2007 - 2008
 */
class HistogramDialog: public Dialog
{
public:
	/**
	 \brief
	 Initialize the dialog.
	 */
	HistogramDialog();

	/**
	 \brief
	 Deconstruct the dialog.
	 */
	virtual ~HistogramDialog() {}

	/**
	 \brief
	 Set the DIB for which the histogram should be showed. HistogramDialog
	 does not own the DIB.

	 \param *dib A pointer to the DIB.
	 */
	void setDIB( DIB *dib );

	/**
	 \brief
	 Handle messages, specific for this dialog box. This function will be
	 called when the dialog box is made visible by show().
	 
	 \param uMsg The message id.
	 \param wParam 32 bits value, specific to the message.
	 \param lParam 32 bits value, specific to the message.
	 \return Typically, the function should return TRUE if it processed the
	   message completely, and FALSE if it did not.
	 */
	virtual BOOL handleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam );

private:
	/**
	 \brief
	 Fill _vector with 256 values, for each possible brightness. Each
	 value is equal to the number of pixels found with that brightness.
	 */
	void getHistogramValues();

	/**
	 The DIB for which the histogram will be generated.
	 */
	DIB *_dib;

	/**
	 The vector to store the histogram data.
	 */
	std::vector<unsigned int> _values;
};
